class Solution {
public:
    int findPoisonedDuration(vector<int>& a, int k) {
        int n = a.size();
        int ans = 0;
        for (int i = 1; i < n; i++) {
            int x = a[i] - a[i - 1];
            if (x >= k)ans += k;
            else ans += x;
        }
        ans += k;
        return ans;
    }
};